%{

# define infolval uceslval

# include <string.h>
# include "parser.h"
# include "uces.tab.h"

extern YYSTYPE infolval;

char * stripUcesString (char *txt) {
	int i;
	char *str = (char *) malloc(sizeof(char)*strlen(txt));
	for (i=1;i<strlen(txt)-1;i++)
		str[i-1] = txt[i];
	str[i-1]='\0';
	return str;
}

%}

digit		[0-9]+
virgula		([0-9]*"."[0-9]+)
string		\'[^\']*\'
numero		a[0-9]+
ucelb		[Uu][cC][eE]
alunolb		[Aa][lL][uU][nN][oO]
nomelb		[nN][oO][mM][eE]
maxstlb		[Mm][aA][xX][Aa][lL][uU][nN][oO][sS]
numerolb	[nN][uUúÚ][mM][eE][rR][oO]

%%


"{"		{ return OPEN; }
"}"		{ return CLOSE; }
"="		{ return EQUAL; }
";"		{ return STOP; }
{ucelb}		{ return LABEL_UCE; }
{nomelb}	{ return LABEL_NAME; }
{maxstlb}	{ return LABEL_MAXSTUDENTS; }

{virgula}       { infolval.virgula = atof(yytext); return FLOAT; }
{digit}		{ infolval.digits = atoi(yytext); return DIGITS; }
{numero}	{ infolval.number = strdup(yytext); return NUMBER; }
{string}        { infolval.string = stripUcesString(yytext); return STRING; }

[" "\n\t]	{ ; }

%%

int yywrap () {
	return 1;
}
